package com.back.model.vo;

import com.back.model.entity.QuestionOptions;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.OrderBy;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 题目表
 * @TableName questions
 */
@Data
public class QuestionsVo {

    private Integer id;

    /**
     * 题目类型 0 单选 1多选 2填空
     */
    private Integer type;

    /**
     * 问题内容
     */
    private String question;

    /**
     * 题目分值
     */
    private BigDecimal score;

    /**
     * 难度
     */
    private Object difficulty;

    /**
     * 正确答案(单选题)
     */
    private String correctAnswer;

    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private String uerCorrectAnswer;

    /**
     * 正确答案(多选题) json
     */
    @JsonIgnore
    private String correctAnswers;

    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private Long examRecordId;

    /**
     * 正确答案(多选题) json
     */
    private List<String> multipleAnswers;

    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<String> uerMultipleAnswers;


    private List<QuestionOptionsVO> questionOptions;

    public QuestionsVo() {
    }

    public QuestionsVo(QuestionsVo questionsVo) {
        this.id = questionsVo.id;
        this.type = questionsVo.type;
        this.question = questionsVo.question;
        this.score = questionsVo.score;
        this.difficulty = questionsVo.difficulty;
        this.correctAnswer = questionsVo.correctAnswer;
        this.correctAnswers = questionsVo.correctAnswers;
        this.multipleAnswers = questionsVo.multipleAnswers;
        // 深拷贝 questionOptions
        if (questionsVo.questionOptions != null) {
            this.questionOptions = questionsVo.questionOptions.stream()
                    .map(QuestionOptionsVO::new) // 假设 QuestionOptionsVO 也有复制构造方法
                    .collect(Collectors.toList());
        }
    }

}